<!DOCTYPE html>
<html>
<include file="Public:header" />
<link href="__ACSS__/dialog.css" rel="stylesheet">
<link href="__ACSS__/plugins/validform/validform.css" rel="stylesheet">
<link href="__ACSS__/plugins/summernote/summernote.css" rel="stylesheet">
<link href="__ACSS__/plugins/summernote/summernote-bs3.css" rel="stylesheet">
<style>
	.form-control{ padding-left:5px;}
	.upload-warp{ position:relative;}
	.upload-btn{ position:absolute; top:0; right:0; border-radius:0;}
	.modal-backdrop{position: relative;}
</style>
  <body>
	  <div class="wrapper wrapper-content animated fadeInRight">
	  	<form role="form" class="form" action="__URL__/update">
			<input type="hidden" name="id" value="<{$vo.id}>">
			<div class="form-group">
				<label class="col-sm-2 control-label">字段名：</label>
				<div class="col-sm-10">
					<input type="text" datatype="*" disabled class="form-control" value="<{$vo.field}>"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">描述：</label>
				<div class="col-sm-10">
					<input type="text" datatype="*" disabled class="form-control" value="<{$vo.content}>"/>
				</div>
			</div>
			<if condition="$vo.type eq 2">
				<div class="form-group">
					<label class="col-sm-2 control-label">内容：</label>
					<div class="col-sm-10">
						<div class="summernote"><{$vo.value}></div>
						<div class="clearfix"></div>
						<textarea class="form-control hide" datatype="*" id="content-input" name="value" rows="3"></textarea>
						<span class="Validform_checktip"></span>
					</div>
				</div>
			<else/>
				<div class="form-group">
					<label class="col-sm-2 control-label">值：</label>
					<div class="col-sm-10">
						<input type="text" datatype="*" name="value" class="form-control" value="<{$vo.value}>"/>
					</div>
				</div>
			</if>
			<div class="clearfix">
				<button type="submit" id="submit" class="btn btn-success btn-block">提交</button>
				<button type="reset" id="reset2" class="btn btn-success btn-block hidden">重置</button>
			</div>
		</form>
	  </div>
  </body>
<!-- 全局js -->
<include file="Public:foot" />
<script src="__AJSPLUGINS__/validform/Validform_v5.3.2_min.js"></script>
<!-- SUMMERNOTE -->
<script src="__AJSPLUGINS__/summernote/summernote.min.js"></script>
<script src="__AJSPLUGINS__/summernote/summernote-zh-CN.js"></script>
<script>
$(function(){
	$('.summernote').summernote({
		height: 200,
        lang: 'zh-CN',
        onImageUpload: function(files, editor, $editable) {
        	sendFile(files[0],editor,$editable);
        }
    });
	$("#reset2").click();
	var index = parent.layer.getFrameIndex(window.name);
	var form = $(".form").Validform({
		tiptype:4,
		ajaxPost:true,
		beforeCheck:function(curform){
			$("#content-input").val($('.summernote').code());
		},
		callback:function(data){
			if(data.status == 1) {
				window.parent.layer.msg(data.info);
				window.parent.$('#table_list').trigger("reloadGrid");
			}else{
				window.parent.layer.msg(data.info);
			}
			parent.layer.close(index);
		}
	});
})

//summernote上传图片
function sendFile(file, editor, $editable){
	var name = new Date().getTime();
	//name是文件名，自己随意定义
	data = new FormData();
	data.append("file", file);
	$.ajax({
		type: "POST",
		url: "__URL__/uploadImgForEditor",
		data: data,
		cache: false,
		contentType: false,
		processData: false,
		success: function(data) {
			var data = eval("("+data+")");
			var url = data[0]['webRoot'] + data[0]['savepath'] + data[0]['savename'];
			editor.insertImage($editable, url);
		},
		error:function(){
			layer.msg("上传失败");
		}
	});
}
</script>
</html>